package chapter1.No1_7_停止线程.d在沉睡中停止;

/**
 * *：这个实验是先sleep再interrupt()
 */
public class MyThread extends Thread {
    @Override
    public void run() {
        try {
            System.out.println("run begin");
            Thread.sleep(2000);
            System.out.println("run end");
        } catch (InterruptedException e) {
            System.out.println("在沉睡中被停止。进入catch!");
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws InterruptedException {
        MyThread m1 = new MyThread();
        m1.start();
        m1.interrupt();
        System.out.println("end");
    }
}
